package cn.maihe.elg.operation.model.enums;

import java.util.Arrays;

/***
 * 审核状态（0未审核 1已审核 2待审核 3审核拒绝）
 */
public enum AuditStatusEnum {
    AUDIT_NO(0, "未审核"),
    AUDITED(1, "已审核"),
    AUDITING(2, "待审核"),
    AUDIT_OUT(3, "外部审核"),
    AUDIT_REJECT(4, "审核拒绝");


    private int value;
    private String label;

    AuditStatusEnum(int value, String label) {
        this.value = value;
        this.label = label;
    }
    public static boolean contains(int type){
        for(AuditStatusEnum typeEnum : AuditStatusEnum.values()){
            if(typeEnum.value == type){
                return true;
            }
        }
        return false;
    }
    public static String getValue(int type){
        for(AuditStatusEnum typeEnum : AuditStatusEnum.values()){
            if(typeEnum.value == type){
                return typeEnum.label;
            }
        }
        return "";
    }
    public int getValue() {
        return value;
    }

    public String getLabel() {
        return label;
    }


    public static AuditStatusEnum resolve(int value) {
        return Arrays.stream(values()).filter(v -> v.value == value).findFirst().orElseThrow(() -> new RuntimeException("担保机构状态值[" + value + "]有误"));
    }

}
